
module UnidadeControle where

import Graphics.UI.GLUT

-- Make
makeUnidadeControle :: Color4 GLfloat -> IO DisplayList
makeUnidadeControle cor = do
	[listaUC] <- genObjectNames 1
	defineList listaUC Compile $ do
		preservingMatrix $ do
			rotate ((-90) :: GLfloat) (Vector3 1 0 0)
			currentColor $= cor
			materialAmbient Front $= cor
			-- Decodificador 4-para-16			
			preservingMatrix $ do
				translate (Vector3 20 10 40 :: Vector3 GLfloat)
				scale 3.5 1.5 (1::GLfloat)
				renderObject Solid (Cube 5)
			--lighting $= Disabled
			preservingMatrix $ do				
				currentColor $= Color4 0 0 0 1				
				translate (Vector3 12 12 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman "Decodificador"
			preservingMatrix $ do
				translate (Vector3 12 8 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman "  4-para-16"			
			-- Memoria
			--lighting $= Enabled
			currentColor $= cor
			materialAmbient Front $= cor
			preservingMatrix $ do
				translate (Vector3 (-20) 35 40 :: Vector3 GLfloat)
				scale 5 2 (1::GLfloat)
				renderObject Solid (Cube 5)
			--lighting $= Disabled
			preservingMatrix $ do
				currentColor $= Color4 0 0 0 1
				translate (Vector3 (-30) 38 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman " Memoria de controle"
			preservingMatrix $ do
				translate (Vector3 (-30) 36 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman "  de 512 x 36 para"
			preservingMatrix $ do
				translate (Vector3 (-30) 34 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman "    armazenar o"
			preservingMatrix $ do
				translate (Vector3 (-30) 32 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman "   microprograma"
			-- MIR
			--lighting $= Enabled
			currentColor $= cor
			materialAmbient Front $= cor
			preservingMatrix $ do
				translate (Vector3 (-20) 22 40 :: Vector3 GLfloat)
				scale 5 1 (1::GLfloat)
				renderObject Solid (Cube 5)
			--lighting $= Disabled
			preservingMatrix $ do
				currentColor $= Color4 0 0 0 1
				translate (Vector3 (-32) 22 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman "Addr|J|ULA|   C    |M|B"
			-- flip-flop N
			--lighting $= Enabled
			currentColor $= cor
			materialAmbient Front $= cor
			preservingMatrix $ do
				translate (Vector3 18 20 40 :: Vector3 GLfloat)
				scale 0.5 0.5 (1::GLfloat)
				renderObject Solid (Cube 5)
			-- flip-flop Z
			currentColor $= cor
			materialAmbient Front $= cor
			preservingMatrix $ do
				translate (Vector3 22 20 40 :: Vector3 GLfloat)
				scale 0.5 0.5 (1::GLfloat)
				renderObject Solid (Cube 5)
			-- Bit de mais alta ordem
			--lighting $= Enabled
			currentColor $= cor
			materialAmbient Front $= cor
			preservingMatrix $ do
				translate (Vector3 20 28 40 :: Vector3 GLfloat)
				scale 2 1.5 (1::GLfloat)
				renderObject Solid (Cube 5)
			--lighting $= Disabled
			preservingMatrix $ do
				currentColor $= Color4 0 0 0 1
				translate (Vector3 15.5 30 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman " Bit de"
			preservingMatrix $ do
				translate (Vector3 15.5 28 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman "mais alta"
			preservingMatrix $ do
				translate (Vector3 15.5 26 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman " ordem"
			-- MPC
			--lighting $= Enabled
			currentColor $= cor
			materialAmbient Front $= cor
			preservingMatrix $ do
				translate (Vector3 5 37 40 :: Vector3 GLfloat)
				scale 3 0.5 (1::GLfloat)
				renderObject Solid (Cube 5)
			--lighting $= Disabled
			preservingMatrix $ do
				currentColor $= Color4 0 0 0 1
				translate (Vector3 3 36.5 42.6 :: Vector3 GLfloat)			
				scale 0.01 0.01 (0.01::GLfloat)
				renderString MonoRoman "MPC"
			-- Quadradin
			--lighting $= Enabled
			currentColor $= cor
			materialAmbient Front $= cor
			preservingMatrix $ do
				translate (Vector3 (-40) 27 40 :: Vector3 GLfloat)
				scale 0.5 0.5 (1::GLfloat)
				renderObject Solid (Cube 5)
	shadeModel $= Flat
	return listaUC